#include <stdlib.h>
#include "bootutil.h"

void * operator new(unsigned long size) { return malloc(size); }

extern "C" char * sbrk(int incr)
{
	unsigned long ret;
	__asm__ __volatile__(
		"mov %1, %%ebx\t\n"
		"int $0x90\t\n"
		"mov %%eax, %0"
		:"=m"(ret):"m"(incr),"Ia"(0x1001)
	);
	return (char *)ret;
}

int main(void)
{
	init_video();
	char * buf = (char *)malloc(0x20);
	char * buf2 = (char *)malloc(0x2000);
	char * buf3 = (char *)malloc(0x30);

	kprintf("buf1: 0x%x\n", buf);
	kprintf("buf2: 0x%x\n", buf2);
	kprintf("buf3: 0x%x\n", buf3);

	free(buf2);
	buf2 = (char *) malloc(0x1000);
	kprintf("buf2: 0x%x\n", buf2);

	const char * name = "initdev";
	__asm__ __volatile__("int $0x90\t\n"::"a"(0x4010),"b"(name), "c"(2), "d"(2)
	);


	while(1);
	return 0;
}

